package com.squirrel.michale;

import java.util.Scanner;

public class LeetCode0849 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String parkingStatus = in.nextLine();
        String[] parkingArray = parkingStatus.split(",");
        int[] parkingIntArray = new int[parkingArray.length];
        for(int i=0; i< parkingArray.length;i++){
            parkingIntArray[i]=Integer.parseInt(parkingArray[i]);
        }
        System.out.println(maxDistanceToCar(parkingIntArray));
    }

    public static int maxDistanceToCar(int[] parkingArray){
        int maxDistance = 0;
        int start = -1;
        int end = -1;
        int lastDistance = 0;
        for(int i=0;i< parkingArray.length;i++){
            if(parkingArray[i] == 0 && maxDistance == 0){
                maxDistance ++;
                start = i;
            }else if(parkingArray[i] == 0 && maxDistance !=0){
                maxDistance ++;
                end = i;
            }else {
                if(start == 0 && maxDistance > 0){
                    lastDistance = maxDistance;
                }else if(end == parkingArray.length-1 && maxDistance >0){
                    lastDistance = lastDistance > maxDistance?lastDistance:maxDistance;
                }else if(maxDistance>0){
                    int mean = (maxDistance+1)/2;
                    lastDistance = lastDistance>mean?lastDistance:mean;
                }
                maxDistance = 0;
                start = -1;
                end = -1;
            }
        }
        if(end == parkingArray.length -1 && maxDistance > 0){
            return lastDistance = lastDistance>maxDistance?lastDistance:maxDistance;
        }
        return lastDistance;
    }
}
